package com.test5;

import java.io.FileOutputStream;
import java.io.OutputStreamWriter;

public class OutputStreamWriterTest {
    public static void main(String[] args) throws Exception {
        FileOutputStream fos = new FileOutputStream("C:\\Users\\LDH\\Desktop\\test.txt");
        OutputStreamWriter osw = new OutputStreamWriter(fos,"gbk");
        //写入
        for (int i = 0; i < 10; i++) {
            osw.write("人生若只如初见\r\n");
            osw.flush();
        }
        //关闭
        osw.close();
        System.out.println("执行完毕");
    }
}
